{% extends "admin/change_list.html" %}
{% load adminmedia admin_list i18n cms_admin cms_js_tags %}
{% block title %}{% trans "List of pages" %}{% endblock %}

{% block bodyclass %}_change-list{% endblock %}

{% if not is_popup %}{% block breadcrumbs %}
    <ul class="breadcrumb">
        <li><a href="../../">{% trans "Home" %}</a> <span class="divider">/</span></li>
        <li><a href="../">{{ app_label|capfirst|escape }}</a> <span class="divider">/</span></li>
        <li>{{ opts.verbose_name_plural|capfirst|escape }}</li>
    </ul>
{% endblock %}{% endif %}

{% block coltype %}flex{% endblock %}
{% block extrahead %}
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}cms/css/pages.css"/>
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}cms/jstree/tree_component.css" />
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}cms/css/jquery.dialog.css" />

{{ block.super }}
<script type="text/javascript" src="{% admin_static_url %}js/jquery.min.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}cms/js/csrf.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}cms/js/libs/jquery.livequery.js"></script>

<script type="text/javascript" src="{{ STATIC_URL }}cms/js/libs/jquery.ui.core.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}cms/js/libs/jquery.bind.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}cms/js/libs/jquery.ui.checkbox.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}cms/js/libs/jquery.ui.effects.core.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}cms/js/libs/jquery.ui.effects.highlight.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}cms/js/libs/jquery.form.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}cms/jstree/_lib/_all.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}cms/jstree/tree_component.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}cms/js/libs/jquery.ui.dialog.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}cms/js/libs/jquery.functional.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}cms/js/libs/classy.min.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}cms/js/plugins/cms.setup.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}cms/js/plugins/cms.base.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}cms/js/change_list.js"></script>


{% if cl.is_filtered %}
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}cms/jstree/themes/default/style.css" />
{% endif %}
{% endblock %}


{% block object-tools %}

    {% if has_recover_permission %}
        <a href="recover/" class="btn recoverlink">{% blocktrans with cl.opts.verbose_name_plural|escape as name %}Recover deleted {{name}}{% endblocktrans %}</a>
    {% endif %}

    {% if has_add_permission %}
      <a href="add/{% if is_popup %}?_popup=1{% endif %}" class="btn btn-primary addlink"><i class="icon-plus icon-white"></i>{% blocktrans with cl.opts.verbose_name as name %}Add {{ name }}{% endblocktrans %}</a>
    {% endif %}


    {% block search %}

      <div class="pull-right">
        {% search_form cl %}
        {% if cl.has_filters %}
          <ul class="nav" id="_changelist-filter">
            <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">{% trans 'Filter' %}<b class="caret"></b></a>
                <ul class="dropdown-menu pull-right">
                  {% for spec in cl.filter_specs %}{% admin_list_filter cl spec %}{% endfor %}
                </ul>
            </li>
          </ul>
        {% endif %}
      </div>

    <div class="module{% if cl.has_filters %} filtered{% endif %}" id="_changelist">
    {% if cl.has_access_to_multiple_sites %}
        <div id="site-selector">{% trans "Pages on:" %}
            <select id="site-select">{% for site in cl.sites %}
                <option {% ifequal site.pk cl.current_site.pk %}selected {% endifequal %}value="{{ site.pk }}">{{ site.name }}</option>{% endfor %}
            </select>
        </div>
    {% else %}
        <input type="hidden" id="site-select" value="{{ cl.sites.0.pk }}">
    {% endif %}
    {% endblock %}
    {% block date_hierarchy %}{% date_hierarchy cl %}{% endblock %}

    {% block filters %}
    {% if cl.has_filters %}


    <a href="javascript:showchangelistfilter();" id="changelist-filter-button">{% trans "Filter:" %} {% if cl.is_filtered %}{% trans "on" %}{% else %}{% trans "off" %}{% endif %}</a>
    <div id="changelist-filter" style="display:none;">
    <h2>{% trans 'Filter' %}</h2>
    {% for spec in cl.filter_specs %}
       {% clean_admin_list_filter cl spec %}
    {% endfor %}
    </div>
    {% endif %}
    {% endblock %}
    </div>
{% endblock %}

{% block content %}

{% include "admin/cms/page/loading.html" %}

<script type="text/javascript">
//<![CDATA[ 
(function($) {
  $(document).ready(function() {
    {% if not cl.is_filtered %}
      initTree();
    {% endif %}   
  });
  
  showchangelistfilter = function(){
    $("#changelist-filter").toggle();
  }
  moveSuccess = function(node){
    var msg = $({% javascript_string %}<span class="success">{% trans "Successfully moved" %}</span>{% end_javascript_string %});
    node.append(msg);
      msg.fadeOut(3000);
  }
  moveError = function(node){
    var msg = $({% javascript_string %}<span class="success">{% trans "An error occured. Please reload the page" %}</span>{% end_javascript_string %});
    node.append(msg);
  }
  // some settings used by javascript functions

  cmsSettings = {
    cmsPermission: {{ CMS_PERMISSION|js }},
    cmsModerator: {{ CMS_MODERATOR|js }},
    debug: {{ DEBUG|js }}
  };
})(jQuery);
//]]>
</script>

<div class="row-fluid">
    <div id="content-main" class="span12">
    {% include "admin/cms/page/change_list_tree.html" %}
    </div>
</div>

{% endblock %}

{% block sidebar %}

<div id="dialogs"></div>

{% endblock sidebar %}